package com.api.regression.group.getmembers;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.MemberApi;
import com.zyncro.api.model.PagedItemsResultApi;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class GetMembersPrivateGroup extends AbstractApiTest {

	@Value("#{groupmembers['user.participant'].appId}")
	private String userUrn;

	@Value("#{groupmembers['user.participant'].password}")
	private String userPassword;

	@Value("#{groupmembers['group.privateToGet'].urn}")
	private String groupUrn;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void testGetGroups() throws ZyncroApiException {

		PagedItemsResultApi<MemberApi> result = getApi().getService(IGroupApiService.class).getMembers(groupUrn, 0, 0);

		Assert.assertTrue(result.getTotalItems() > 0);
	}
}
